﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Ycm20250401.Service._20250408
{
    public class AlipayAdapter : IPaymentProvider
    {
        private readonly AlipayService _alipay;

        public AlipayAdapter(AlipayService alipay) => _alipay = alipay;

        public async Task<PaymentResult> PayAsync(decimal amount, string orderId, object metadata)
        {
            // 转换参数调用支付宝SDK
            var transactionId = await _alipay.AliPay(amount, orderId);

            // 统一返回结构
            return new PaymentResult(
                transactionId,
                orderId,
                amount,
                "CNY",
                DateTime.Now
            );
        }
    }
}